home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 October / EnigmA AMIGA RUN 31 (1998)(G.R. Edizioni)(IT)[!][issue 1998-10].iso / earkit / browser / aweb31_patch / docs / docsearch.awebrx < prev    next >
Text File  |  1998-09-22  |  5KB  |  135 lines

  1. /*******************************************************************
  2.  *                                                                 *
  3.  * Docsearch.awebrx                                                *
  4.  *                                                                 *
  5.  * © 1997 Yvon Rozijn                                              *
  6.  *                                                                 *
  7.  * Search in AWeb documentation. Generate index if requested or    *
  8.  * no index file exists yet. Search the index file and pass        *
  9.  * results on to AWeb.                                             *
  10.  *                                                                 *
  11.  *******************************************************************/
  12.  
  13. /*******************************************************************
  14.  *                                                                 *
  15.  * To use this as a search engine for your own set of local HTML   *
  16.  * files, adjust the following variables:                          *
  17.  *                                                                 *
  18.  * index = path of index file                                      */
  19.  
  20. index = 'AWebPAth:docs/docsearch.index'
  21.  
  22. /* makeindex = full command line to make the index.                *
  23.  * The makeindex program takes template: DIR/A/M,TO/A              *
  24.  * DIR = directories to search for #?.html files (not recursive)   *
  25.  * TO = name of index file to create                               */
  26.  
  27. makeindex = 'AWebPath:docs/makeindex AWebPath:docs AWebPath:docs/plugins AWebPath:docs/settings AWebPath:docs/arexx' index
  28.  
  29. /* resultfile = path of file to store search result                */
  30.  
  31. resultfile = 'T:docsearch'
  32.  
  33. /* searchindex = full command line to search the index, the search *
  34.  * argument will be appended.                                      *
  35.  * The searchindex program takes template: INDEX/A,TO/A,SEARCH/A/F *
  36.  * INDEX = path of index file                                      *
  37.  * TO = path of search result                                      *
  38.  * SEARCH = string to search                                       */
  39.  
  40. searchindex = 'AWebPath:docs/searchindex' index resultfile
  41.  
  42. /* and adjust the HTML used in the search result to fit your       *
  43.  * application.                                                    *
  44.  *                                                                 *
  45.  *******************************************************************/
  46.  
  47. options results
  48. options failat 20
  49.  
  50. parse source dummy1 dummy2 programname .
  51.  
  52. parse arg sarg
  53.  
  54. search=''
  55. regenerate=''
  56. interpret sarg
  57.  
  58. if search='' & regenerate='' then exit
  59.  
  60. su=upper(search)
  61.  
  62. nl='0a'x
  63.  
  64. if regenerate~='' | ~exists(index) then do
  65.    'chanopen "x-nil:docsearch/creating index"'
  66.    ch=result
  67.    
  68.    'open "x-nil:docsearch/creating index"'
  69.    
  70.    'chanheader' ch '"content-type: text/html"'
  71.    'chanheader' ch '"pragma: no-cache"'
  72.    
  73.    doc='<HTML><TITLE>Creating search index</TITLE>*N'
  74.    doc=doc || '<BODY><H1>Creating index</H1>*N'
  75.    doc=doc || 'A search index is being created. Please be patient...'
  76.    
  77.    'chandata' ch '"' || doc || '" nl'
  78.    'chanclose' ch
  79.    
  80.    address command makeindex
  81. end
  82.  
  83. if search='' then do
  84.    'go back'
  85.    exit
  86. end
  87.  
  88. if ~exists(index) then exit
  89.  
  90. 'chanopen "file:///nil:docsearch/' || search || '"'
  91. ch=result
  92.  
  93. 'chanheader' ch '"content-type: text/html"'
  94. 'chanheader' ch '"pragma: no-cache"'
  95.  
  96. doc='<HTML><TITLE>Search result:' search '</TITLE>*N'
  97. doc=doc || '<BASE HREF=file:///AWebPath:docs/aweb.html>*N'
  98. doc=doc || '<BODY BACKGROUND=awebbg.iff>*N'
  99. doc=doc || '<H1><IMG SRC=aweb.iff width=192 height=93 alt=(logo)>  Search result:' search '</H1>*N'
  100.  
  101. 'chandata' ch '"' || doc || '" nl'
  102.  
  103. doc='<FORM ACTION=x-aweb:rexx/' || programname || '>*N'
  104. doc=doc || 'Search in documentation: <input name=search size=25 value=*"' || search || '*"> <input type=submit value=Search>*N'
  105. doc=doc || '</FORM>*N'
  106. doc=doc || '<OL>'
  107.  
  108. 'chandata' ch '"' || doc || '" nl'
  109.  
  110. 'open "file:///nil:docsearch/' || search || '"'
  111. 'allowcmd'
  112.  
  113. address command searchindex '"' || search || '"'
  114.  
  115. if open(f,resultfile,'R') then do
  116.    do until length(block)<480
  117.       block=readch(f,480)
  118.       'chandata' ch '"' || block || '"'
  119.    end
  120.    call close f
  121.    address command 'delete' resultfile 'quiet'
  122. end
  123.  
  124. doc='</OL>*N'
  125. doc=doc || '<HR><A HREF=file:///AWebPath:docs/aweb.html>Back to index</a>*N'
  126.  
  127. doc=doc || '<BR><BR><HR><FORM ACTION=x-aweb:rexx/' || programname || '>*N'
  128. doc=doc || '<B>TIP:</B> After you have added new documentation files,*N'
  129. doc=doc || '<INPUT TYPE=SUBMIT NAME=Regenerate VALUE=Regenerate>*N'
  130. doc=doc || 'the search index for correct search results.*N</FORM>'
  131.  
  132. 'chandata' ch '"' || doc || '" nl'
  133. 'chanclose' ch
  134.  
  135.